package com.mmy.controller.constzone;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.mmy.domain.constzone.TConstZone;
import com.mmy.domain.plane.VPlaneAirport;
import com.mmy.domain.ship.VShipPort;
import com.mmy.domain.train.VTrainStation;
import com.mmy.service.impl.constzone.ConstZoneServiceImpl;
import com.mmy.service.plane.impl.TPlaneAirportServiceImpl;
import com.mmy.service.ship.impl.TShipPortServiceImpl;
import com.mmy.service.train.impl.TrainStationServiceImpl;

/**
 * 类的介绍：签证收集信息
 *
 * @author hanxl
 * @date 2020-07-23
 * @version 1.0
 */
@Controller
public class ConstZoneController {

	@Autowired
	ConstZoneServiceImpl constZoneServiceImpl;
	@Autowired
	TPlaneAirportServiceImpl tPlaneAirportServiceImpl;
	@Autowired
	TShipPortServiceImpl tShipPortServiceImpl;
	@Autowired
	TrainStationServiceImpl tTrainStationServiceImpl;

	@ResponseBody
	@RequestMapping(value = "getLevel1")
	public Object getLevel1() {

		List<TConstZone> listContinents = constZoneServiceImpl.findContinents();

		return listContinents;
	}

	@ResponseBody
	@RequestMapping(value = "getLevel2")
	public Object getLevel2(String level1) {

		List<TConstZone> listCountriess = constZoneServiceImpl.findCountriess(Integer.parseInt(level1));

		return listCountriess;
	}
	
	//省3
	@ResponseBody
	@RequestMapping(value = "getLevel3")
	public Object getLevel3(String level2) {
		List<TConstZone> listProvince = constZoneServiceImpl.findProvince();
		System.out.println(JSONObject.toJSONString(listProvince));
		return listProvince;
	}
	
	
	
	//市4
	@ResponseBody
	@RequestMapping(value = "getLevel4")
	public Object getLevel4(String level3) {
		
		List<TConstZone> listCities = constZoneServiceImpl.findCities(Integer.parseInt(level3));

		return listCities;
	}

	@ResponseBody
	@RequestMapping(value = "getLevel5")
	public Object getLevel5(String level2) {

		List<VPlaneAirport> listAirport = tPlaneAirportServiceImpl.findAirport(Integer.parseInt(level2));

		return listAirport;
	}

	@ResponseBody
	@RequestMapping(value = "getLevel6")
	public Object getLevel6(String level2) {

		List<VShipPort> listport = tShipPortServiceImpl.findport(Integer.parseInt(level2));

		return listport;
	}

	@ResponseBody
	@RequestMapping(value = "getLevel7")
	public Object getLevel7(String level4) {

		List<VTrainStation> listStation = tTrainStationServiceImpl.findStation(Integer.parseInt(level4));

		return listStation;
	}
	
	//区8
	@ResponseBody
	@RequestMapping(value = "getLevel8")
	public Object getLevel8(String level4) {

		List<TConstZone> listAreas = constZoneServiceImpl.findAreas(Integer.parseInt(level4));

		return listAreas;
	}
	//新三级联动 搜索场景
	@RequestMapping("getProvince")
	@ResponseBody
	public String getProvince(){
		List<Map<String,Object>> lstProvince = constZoneServiceImpl.getAllProvince();
		Map<String,Object> mapTips = new HashMap<String, Object>();
		mapTips.put("iZoneID", "");
		mapTips.put("cZoneName", "不限");
		lstProvince.add(0,mapTips);
		return JSONObject.toJSONString(lstProvince);
	}
	
	@RequestMapping("getCity")
	@ResponseBody
	public String getCity(String zoneID){
		List<Map<String,Object>> lstCity = constZoneServiceImpl.getCities(Integer.parseInt(zoneID));
		Map<String,Object> mapTips = new HashMap<String, Object>();
		mapTips.put("iZoneID", "");
		mapTips.put("cZoneName", "不限");
		lstCity.add(0,mapTips);
		return JSONObject.toJSONString(lstCity);
	}
	
	@RequestMapping("getArea")
	@ResponseBody
	public String getArea(String zoneID){
		List<Map<String,Object>> lstArea = constZoneServiceImpl.getAreas(Integer.parseInt(zoneID));
		Map<String,Object> mapTips = new HashMap<String, Object>();
		mapTips.put("iZoneID", "");
		mapTips.put("cZoneName", "不限");
		lstArea.add(0,mapTips);
		return JSONObject.toJSONString(lstArea);
	}
	//新三级联动 创建场景
		@RequestMapping("createProvince")
		@ResponseBody
		public String createProvince(){
			List<Map<String,Object>> lstProvince = constZoneServiceImpl.getAllProvince();
			Map<String,Object> mapTips = new HashMap<String, Object>();
			mapTips.put("iZoneID", "");
			mapTips.put("cZoneName", "---请选择---");
			lstProvince.add(0,mapTips);
			return JSONObject.toJSONString(lstProvince);
		}
		
		@RequestMapping("createCity")
		@ResponseBody
		public String createCity(String zoneID){
			List<Map<String,Object>> lstCity = constZoneServiceImpl.getCities(Integer.parseInt(zoneID));
			Map<String,Object> mapTips = new HashMap<String, Object>();
			mapTips.put("iZoneID", "");
			mapTips.put("cZoneName", "---请选择---");
			lstCity.add(0,mapTips);
			return JSONObject.toJSONString(lstCity);
		}
		
		@RequestMapping("createArea")
		@ResponseBody
		public String createArea(String zoneID){
			List<Map<String,Object>> lstArea = constZoneServiceImpl.getAreas(Integer.parseInt(zoneID));
			Map<String,Object> mapTips = new HashMap<String, Object>();
			mapTips.put("iZoneID", "");
			mapTips.put("cZoneName", "---请选择---");
			lstArea.add(0,mapTips);
			return JSONObject.toJSONString(lstArea);
		}
}
